
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

    <title>Deploying LXC devices &#8212; LAVA 2024.05 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.js"></script>
    <link rel="shortcut icon" href="_static/favicon.ico"/>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Deploying an ipmi/pxe-boot Device" href="ipmi-pxe-deploy.html" />
    <link rel="prev" title="PDUDaemon" href="pdudaemon.html" />
    <link rel="canonical" href="https://docs.lavasoftware.org/lava/admin-lxc-deploy.html" />
  
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="_static/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>


  </head><body>

  <div id="navbar" class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="index.html"><span><img src="_static/lava.png"></span>
          LAVA</a>
        <span class="navbar-text navbar-version pull-left"><b>2024.05</b></span>
      </div>

        <div class="collapse navbar-collapse nav-collapse">
          <ul class="nav navbar-nav">
            
                <li><a href="genindex.html">Index</a></li>
                <li><a href="contents.html">Contents</a></li>
            
            
              <li class="dropdown globaltoc-container">
  <a role="button"
     id="dLabelGlobalToc"
     data-toggle="dropdown"
     data-target="#"
     href="index.html">Site <b class="caret"></b></a>
  <ul class="dropdown-menu globaltoc"
      role="menu"
      aria-labelledby="dLabelGlobalToc"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index.html">Introduction to LAVA</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="contents.html">Contents</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary of terms</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="support.html">Getting support</a></li>
</ul>
</ul>
</li>
              
                <li class="dropdown">
  <a role="button"
     id="dLabelLocalToc"
     data-toggle="dropdown"
     data-target="#"
     href="#">Page <b class="caret"></b></a>
  <ul class="dropdown-menu localtoc"
      role="menu"
      aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">Deploying LXC devices</a><ul>
<li><a class="reference internal" href="#prerequisite">Prerequisite</a></li>
<li><a class="reference internal" href="#android-testing-with-lxc-support">Android testing with LXC support</a></li>
<li><a class="reference internal" href="#arbitrary-external-devices-needing-lxc-support">Arbitrary external devices needing LXC support</a><ul>
<li><a class="reference internal" href="#usb-attached-devices">USB attached devices</a></li>
<li><a class="reference internal" href="#other-related-devices">Other related devices</a></li>
</ul>
</li>
<li><a class="reference internal" href="#configuration">Configuration</a><ul>
<li><a class="reference internal" href="#persistent-containers">Persistent Containers</a></li>
<li><a class="reference internal" href="#unprivileged-containers-as-root">Unprivileged containers as root</a></li>
</ul>
</li>
<li><a class="reference internal" href="#other-resources">Other resources</a></li>
</ul>
</li>
</ul>
</ul>
</li>
              
            
            
              
                
  <li>
    <a href="pdudaemon.html" title="Previous Chapter: PDUDaemon"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">&laquo; PDUDaemon</span>
    </a>
  </li>
  <li>
    <a href="ipmi-pxe-deploy.html" title="Next Chapter: Deploying an ipmi/pxe-boot Device"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">Deploying an ... &raquo;</span>
    </a>
  </li>
              
            
            
            
            
              <li class="hidden-sm"></li>
            
          </ul>

          
            
<form class="navbar-form navbar-right" action="search.html" method="get">
 <div class="form-group">
  <input type="text" name="q" class="form-control" placeholder="Search" />
 </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>
          
        </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="body col-md-12 content" role="main">
      
  <section id="deploying-lxc-devices">
<span id="lxc-deploy"></span><span id="index-0"></span><h1>Deploying LXC devices<a class="headerlink" href="#deploying-lxc-devices" title="Permalink to this heading">¶</a></h1>
<p>LXC is a userspace interface for the Linux kernel containment features. Through
a powerful API and simple tools, it lets Linux users easily create and manage
system or application containers. LXC devices can run lava tests within a
container without disturbing the dispatcher host. The prime advantage of having
LXC device in LAVA is the ability to provide a transparent, sandboxed
environment with support for different OS types, enabling testing in different
platforms.</p>
<section id="prerequisite">
<h2>Prerequisite<a class="headerlink" href="#prerequisite" title="Permalink to this heading">¶</a></h2>
<p>Ensure that LXC is installed in your LAVA dispatcher host, if not use the
following command to install LXC in Debian:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt install lxc
</pre></div>
</div>
<p>Refer the following links in order to setup networking for LXC in Debian:</p>
<ul class="simple">
<li><p>Network setup - <a class="reference external" href="https://wiki.debian.org/LXC#network_setup">https://wiki.debian.org/LXC#network_setup</a></p></li>
<li><p>Simple Bridge - <a class="reference external" href="https://wiki.debian.org/LXC/SimpleBridge">https://wiki.debian.org/LXC/SimpleBridge</a></p></li>
<li><p>Masqueraded Bridge - <a class="reference external" href="https://wiki.debian.org/LXC/MasqueradedBridge">https://wiki.debian.org/LXC/MasqueradedBridge</a></p></li>
<li><p>VLAN Networking - <a class="reference external" href="https://wiki.debian.org/LXC/VlanNetworking">https://wiki.debian.org/LXC/VlanNetworking</a></p></li>
<li><p>libvirt - <a class="reference external" href="https://wiki.debian.org/LXC/LibVirtDefaultNetwork">https://wiki.debian.org/LXC/LibVirtDefaultNetwork</a></p></li>
</ul>
</section>
<section id="android-testing-with-lxc-support">
<span id="add-android-devices-lxc"></span><h2>Android testing with LXC support<a class="headerlink" href="#android-testing-with-lxc-support" title="Permalink to this heading">¶</a></h2>
<p><a class="reference internal" href="actions-protocols.html#lxc-protocol-reference"><span class="std std-ref">LXC protocol</span></a> is used for Android testing
use-cases which removes the need for writing complex job definitions using
<a class="reference internal" href="multinode.html#multinode"><span class="std std-ref">Multinode</span></a>. This is made possible by adding the usb path of
the <a class="reference internal" href="glossary.html#term-DUT"><span class="xref std std-term">DUT</span></a> that is attached to the dispatcher. The device configuration
takes a special parameter called <cite>device_info</cite> which will be used to expose the
<a class="reference internal" href="glossary.html#term-DUT"><span class="xref std std-term">DUT</span></a> to LXC for Android testing. The <cite>device_info</cite> takes a list of
dictionaries, where each dictionary value can contain keys such as <cite>board_id</cite>,
<cite>usb_vendor_id</cite>, <cite>usb_product_id</cite>.</p>
<p>Examples of <cite>device_info</cite> configuration are as follows.</p>
<p>Example 1 - Single device with just <cite>board_id</cite></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="o">%</span> <span class="nb">set</span> <span class="n">device_info</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;0123456789&#39;</span><span class="p">}]</span> <span class="o">%</span><span class="p">}</span>
</pre></div>
</div>
<p>Example 2 - Single device with <cite>board_id</cite> and <cite>usb_vendor_id</cite></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="o">%</span> <span class="nb">set</span> <span class="n">device_info</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;0123456789&#39;</span><span class="p">,</span> <span class="s1">&#39;usb_vendor_id&#39;</span><span class="p">:</span> <span class="s1">&#39;0451&#39;</span><span class="p">}]</span> <span class="o">%</span><span class="p">}</span>
</pre></div>
</div>
<p>Example 3 - Single device with <cite>board_id</cite>, <cite>usb_vendor_id</cite> and <cite>usb_product_id</cite></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="o">%</span> <span class="nb">set</span> <span class="n">device_info</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;0123456789&#39;</span><span class="p">,</span> <span class="s1">&#39;usb_vendor_id&#39;</span><span class="p">:</span> <span class="s1">&#39;0451&#39;</span><span class="p">,</span> <span class="s1">&#39;usb_product_id&#39;</span><span class="p">:</span> <span class="s1">&#39;d109&#39;</span><span class="p">}]</span> <span class="o">%</span><span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Do not run <cite>adb daemon</cite> on the dispatcher host, which will grab the
<a class="reference internal" href="glossary.html#term-DUT"><span class="xref std std-term">DUT</span></a> and will hinder exposing it to LXC. Similarly, remove
<cite>fastboot</cite> packages from the dispatcher host.</p>
</div>
<div class="code yaml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">commands</span><span class="p">:</span>
    <span class="n">connect</span><span class="p">:</span> <span class="n">telnet</span> <span class="n">localhost</span> <span class="mi">0000</span>
    <span class="n">hard_reset</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="nb">bin</span><span class="o">/</span><span class="n">pduclient</span> <span class="o">--</span><span class="n">daemon</span> <span class="n">services</span> <span class="o">--</span><span class="n">hostname</span> <span class="n">pdu00</span> <span class="o">--</span><span class="n">command</span> <span class="n">reboot</span> <span class="o">--</span><span class="n">port</span> <span class="mi">00</span>
    <span class="n">power_off</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="nb">bin</span><span class="o">/</span><span class="n">pduclient</span> <span class="o">--</span><span class="n">daemon</span> <span class="n">services</span> <span class="o">--</span><span class="n">hostname</span> <span class="n">pdu00</span> <span class="o">--</span><span class="n">command</span> <span class="n">off</span> <span class="o">--</span><span class="n">port</span> <span class="mi">00</span>
    <span class="n">power_on</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="nb">bin</span><span class="o">/</span><span class="n">pduclient</span> <span class="o">--</span><span class="n">daemon</span> <span class="n">services</span> <span class="o">--</span><span class="n">hostname</span> <span class="n">pdu00</span> <span class="o">--</span><span class="n">command</span> <span class="n">on</span> <span class="o">--</span><span class="n">port</span> <span class="mi">00</span>
    <span class="n">pre_power_command</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">lab</span><span class="o">-</span><span class="n">scripts</span><span class="o">/</span><span class="n">usb_hub_control</span> <span class="o">-</span><span class="n">p</span> <span class="mi">0000</span> <span class="o">-</span><span class="n">m</span> <span class="n">sync</span> <span class="o">-</span><span class="n">u</span> <span class="mi">00</span>
<span class="n">device_type</span><span class="p">:</span> <span class="n">hi6220</span><span class="o">-</span><span class="n">hikey</span>
<span class="n">adb_serial_number</span><span class="p">:</span> <span class="mi">12312</span><span class="n">BA123B123B1</span>
<span class="n">fastboot_serial_number</span><span class="p">:</span> <span class="mi">12312</span><span class="n">BA123B123B1</span>
<span class="n">fastboot_options</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;-S&#39;</span><span class="p">,</span> <span class="s1">&#39;256M&#39;</span><span class="p">]</span>
<span class="n">device_info</span><span class="p">:</span> <span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;12312BA123B123B1&#39;</span><span class="p">}]</span>  <span class="c1"># It is a list of dictionaries</span>

<span class="n">actions</span><span class="p">:</span>
  <span class="n">deploy</span><span class="p">:</span>
    <span class="n">methods</span><span class="p">:</span>
      <span class="n">lxc</span><span class="p">:</span>
      <span class="n">fastboot</span><span class="p">:</span>
    <span class="n">connections</span><span class="p">:</span>
      <span class="n">lxc</span><span class="p">:</span>
      <span class="n">serial</span><span class="p">:</span>
  <span class="n">boot</span><span class="p">:</span>
    <span class="n">connections</span><span class="p">:</span>
      <span class="n">lxc</span><span class="p">:</span>
      <span class="n">serial</span><span class="p">:</span>
    <span class="n">methods</span><span class="p">:</span>
      <span class="n">uefi</span><span class="o">-</span><span class="n">menu</span><span class="p">:</span>
        <span class="n">parameters</span><span class="p">:</span>
          <span class="n">interrupt_prompt</span><span class="p">:</span> <span class="s2">&quot;Android Fastboot mode&quot;</span>
          <span class="n">interrupt_string</span><span class="p">:</span> <span class="s1">&#39;x&#39;</span>
          <span class="n">item_markup</span><span class="p">:</span>
            <span class="o">-</span> <span class="s2">&quot;[&quot;</span>
            <span class="o">-</span> <span class="s2">&quot;]&quot;</span>
          <span class="n">item_class</span><span class="p">:</span> <span class="s1">&#39;0-9&#39;</span>
          <span class="n">separator</span><span class="p">:</span> <span class="s1">&#39; &#39;</span>
          <span class="n">label_class</span><span class="p">:</span> <span class="s1">&#39;a-zA-Z0-9\s\:&#39;</span>
          <span class="n">bootloader_prompt</span><span class="p">:</span> <span class="s1">&#39;Start:&#39;</span>
          <span class="n">boot_message</span><span class="p">:</span> <span class="s2">&quot;Booting Linux Kernel...&quot;</span>
          <span class="n">character_delay</span><span class="p">:</span> <span class="mi">10</span>
        <span class="n">fastboot</span><span class="p">:</span>
        <span class="o">-</span> <span class="n">select</span><span class="p">:</span>
            <span class="n">items</span><span class="p">:</span>
             <span class="o">-</span> <span class="s1">&#39;boot from eMMC&#39;</span>

<span class="n">timeouts</span><span class="p">:</span>
  <span class="n">actions</span><span class="p">:</span>
    <span class="n">apply</span><span class="o">-</span><span class="n">overlay</span><span class="o">-</span><span class="n">image</span><span class="p">:</span>
      <span class="n">seconds</span><span class="p">:</span> <span class="mi">120</span>
    <span class="n">umount</span><span class="o">-</span><span class="n">retry</span><span class="p">:</span>
      <span class="n">seconds</span><span class="p">:</span> <span class="mi">45</span>
    <span class="n">lava</span><span class="o">-</span><span class="n">test</span><span class="o">-</span><span class="n">shell</span><span class="p">:</span>
      <span class="n">seconds</span><span class="p">:</span> <span class="mi">600</span>
    <span class="n">power_off</span><span class="p">:</span>
      <span class="n">seconds</span><span class="p">:</span> <span class="mi">10</span>
</pre></div>
</div>
</section>
<section id="arbitrary-external-devices-needing-lxc-support">
<span id="add-usb-devices-lxc"></span><span id="index-1"></span><h2>Arbitrary external devices needing LXC support<a class="headerlink" href="#arbitrary-external-devices-needing-lxc-support" title="Permalink to this heading">¶</a></h2>
<p>Some test devices have attached hardware which needs to be visible from the LXC
during the time that the test job is running.</p>
<ul class="simple">
<li><p>If the attached device re-enumerates on the worker each time that the
<a class="reference internal" href="glossary.html#term-DUT"><span class="xref std std-term">DUT</span></a> is rebooted then <code class="docutils literal notranslate"><span class="pre">device_info</span></code> can be used.</p></li>
<li><p>More commonly, the attached device is independent of the <a class="reference internal" href="glossary.html#term-DUT"><span class="xref std std-term">DUT</span></a> and
is accessible to the worker even when the DUT is powered off. These attached
devices need to use <code class="docutils literal notranslate"><span class="pre">static_info</span></code>.</p>
<ul>
<li><p>Static USB devices (using <code class="docutils literal notranslate"><span class="pre">board_id</span></code>, <code class="docutils literal notranslate"><span class="pre">usb_vendor_id</span></code> or
<code class="docutils literal notranslate"><span class="pre">usb_product_id</span></code>) will be added to the LXC at the start of the test job,
including associated <code class="docutils literal notranslate"><span class="pre">/dev/</span></code> nodes like <code class="docutils literal notranslate"><span class="pre">/dev/tty*</span></code> or
<code class="docutils literal notranslate"><span class="pre">/dev/serial/by-id/</span></code> etc. Test writers will need to locate the correct
device by inspecting paths like <code class="docutils literal notranslate"><span class="pre">/dev/serial/by-id/</span></code>.</p></li>
<li><p>Other static devices which are accessible over the network can be made
available to a test shell in the LXC through lava test shell helpers.</p></li>
</ul>
</li>
</ul>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="lava-scheduler-device-dictionary.html#device-dictionary-commands"><span class="std std-ref">Commands</span></a></p>
</div>
<p>One example is an energy probe, which may be measuring a single DUT whilst
being connected to the worker as a USB or network device.</p>
<p>For a USB probe, the <code class="docutils literal notranslate"><span class="pre">id</span></code> of that USB device needs to be in the
<code class="docutils literal notranslate"><span class="pre">static_info</span></code> of the DUT so that the test shell running in the LXC can
control the probe.</p>
<p>For a network attached probe, the IP address of the probe and the channel which
the probe uses for this specific DUT need to be in the <code class="docutils literal notranslate"><span class="pre">static_info</span></code>.</p>
<section id="usb-attached-devices">
<h3>USB attached devices<a class="headerlink" href="#usb-attached-devices" title="Permalink to this heading">¶</a></h3>
<p>The value for <code class="docutils literal notranslate"><span class="pre">board_id</span></code> in the <code class="docutils literal notranslate"><span class="pre">static_info</span></code> is what shows up in
<code class="docutils literal notranslate"><span class="pre">pyudev</span></code> bindings as the <code class="docutils literal notranslate"><span class="pre">ID_SERIAL_SHORT</span></code>. This is typically the
<code class="docutils literal notranslate"><span class="pre">SerialNumber</span></code> reported by <code class="docutils literal notranslate"><span class="pre">dmesg</span></code> but it is worth checking as the precise
syntax does matter and can differ between <code class="docutils literal notranslate"><span class="pre">pyudev</span></code> and <code class="docutils literal notranslate"><span class="pre">dmesg</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">pyudev</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">context</span> <span class="o">=</span> <span class="n">pyudev</span><span class="o">.</span><span class="n">Context</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span> <span class="n">device</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;ID_SERIAL_SHORT&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">device</span> <span class="ow">in</span> <span class="n">context</span><span class="o">.</span><span class="n">list_devices</span><span class="p">(</span><span class="n">subsystem</span><span class="o">=</span><span class="s1">&#39;usb&#39;</span><span class="p">)]</span>
<span class="go">[u&#39;0000:00:1a.0&#39;, None, None, None, None, u&#39;889FFAE94013&#39;, None, None, None, None,</span>
<span class="go">None, u&#39;FTGNRL22&#39;, None, None, None, u&#39;S_NO62200001&#39;, None, None, None, None,</span>
<span class="go">None, None, None, None, None, u&#39;0000:00:1d.0&#39;, None, None, None]</span>
<span class="go">&gt;&gt;&gt;</span>
</pre></div>
</div>
<p>For <code class="docutils literal notranslate"><span class="pre">usb_vendor_id</span></code>, the corresponding pyudev key is <code class="docutils literal notranslate"><span class="pre">ID_VENDOR_ID</span></code>.
For <code class="docutils literal notranslate"><span class="pre">usb_product_id</span></code>, the corresponding pyudev key is <code class="docutils literal notranslate"><span class="pre">ID_MODEL_ID</span></code>.</p>
<p>The keys given in the dictionary are <strong>not</strong> arbitrary and follow the same
rules as for <a class="reference internal" href="#add-android-devices-lxc"><span class="std std-ref">Android devices</span></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;S_NO62200001&#39;</span><span class="p">}]</span>
</pre></div>
</div>
<div class="admonition caution">
<p class="admonition-title">Caution</p>
<p>Ensure that the <code class="docutils literal notranslate"><span class="pre">static_info</span></code> relates to a USB device which is
attached to the same worker as the DUT but is <strong>not</strong> a DUT itself.</p>
</div>
<p>If using multiple keys for the same <code class="docutils literal notranslate"><span class="pre">device_info</span></code>, ensure that the key value
pairs are in a single dictionary within the list of dictionaries:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="o">%</span> <span class="nb">set</span> <span class="n">static_info</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;0123456789&#39;</span><span class="p">},</span> <span class="p">{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;adsd0978775&#39;</span><span class="p">,</span> <span class="s1">&#39;usb_vendor_id&#39;</span><span class="p">:</span> <span class="s1">&#39;ACME54321&#39;</span><span class="p">}]</span> <span class="o">%</span><span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Devices which include a forward slash <code class="docutils literal notranslate"><span class="pre">/</span></code> in the serial number will have
that replaced by an underscore when processed through <code class="docutils literal notranslate"><span class="pre">pyudev</span></code>. e.g.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">udev</span><span class="p">:</span> <span class="n">ATTRS</span><span class="p">{</span><span class="n">serial</span><span class="p">}</span><span class="o">==</span><span class="s2">&quot;S/NO44440001&quot;</span>
<span class="n">pydev</span><span class="p">:</span> <span class="n">S_NO44440001</span>
<span class="n">static_info</span><span class="p">:</span> <span class="p">{</span><span class="o">%</span> <span class="nb">set</span> <span class="n">static_info</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;board_id&#39;</span><span class="p">:</span> <span class="s1">&#39;S_NO44440001&#39;</span><span class="p">}]</span> <span class="o">%</span><span class="p">}</span>
</pre></div>
</div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>LAVA instances running systemd newer than build 232 (e.g.
Buster) need to allow scripts called by <code class="docutils literal notranslate"><span class="pre">udev</span></code> rules to access the
network to get proper logging of the addition of dynamic USB devices
to the LXC. LAVA achieves this by providing an override file for the
<code class="docutils literal notranslate"><span class="pre">systemd-udev.service`</span> <span class="pre">in</span>
<span class="pre">``/etc/systemd/system/systemd-udevd.service.d/override.conf</span></code>. The
actual network change is not visible in the systemd show support for
the udev service, so the override also updates the unit description
to make it obvious. When this override is in effect, you will be
able to see the change:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo systemctl status udev
systemd-udevd.service - udev Kernel Device Manager (LAVA)
Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
Drop-In: /etc/systemd/system/systemd-udevd.service.d
         -override.conf
</pre></div>
</div>
</div>
</section>
<section id="other-related-devices">
<h3>Other related devices<a class="headerlink" href="#other-related-devices" title="Permalink to this heading">¶</a></h3>
<p>Devices which are not directly attached to the worker can also be supported,
for example energy probes which communicate over the network:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="o">%</span> <span class="nb">set</span> <span class="n">static_info</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;probe_ip&#39;</span><span class="p">:</span> <span class="s1">&#39;192.168.0.23&#39;</span><span class="p">,</span> <span class="s1">&#39;probe_channel&#39;</span><span class="p">:</span> <span class="s1">&#39;4&#39;</span><span class="p">}]</span> <span class="o">%</span><span class="p">}</span>
</pre></div>
</div>
<ul class="simple">
<li><p><strong>probe_ip</strong> - The IP address at which the energy probe is accessible from
the LXC.</p></li>
<li><p><strong>probe_channel</strong>  - Energy probes can often measure multiple devices at once,
so the device dictionary needs to specify the channel so that the test job
can know what channel refers to this LAVA device.</p></li>
</ul>
<p>These values can be retrieved by test writers inside a LAVA test shell in the
LXC by using the associated test shell helpers.</p>
<ul>
<li><p><strong>lava-probe-ip</strong> - echoes the <code class="docutils literal notranslate"><span class="pre">probe_ip</span></code> specified in the device
dictionary.</p></li>
<li><p><strong>lava-probe-channel</strong> - echoes the <code class="docutils literal notranslate"><span class="pre">probe_channel</span></code> specified in the device
dictionary.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference external" href="https://github.com/ARM-software/lisa/wiki/Energy-Meters-Requirements#user-content-iiocapture---baylibre-acme-cape">https://github.com/ARM-software/lisa/wiki/Energy-Meters-Requirements#user-content-iiocapture—baylibre-acme-cape</a></p>
</div>
</li>
</ul>
</section>
</section>
<section id="configuration">
<h2>Configuration<a class="headerlink" href="#configuration" title="Permalink to this heading">¶</a></h2>
<section id="persistent-containers">
<h3>Persistent Containers<a class="headerlink" href="#persistent-containers" title="Permalink to this heading">¶</a></h3>
<p>A test job can request a persistent container which will not get destroyed after
the test job is complete. This allows the container to be reused for subsequent test
jobs. This is useful when users want to setup some software on a container and
use it for subsequent test jobs without re-creating the setup every time, which
may prove time consuming.</p>
<p>In such a case the admins can choose to switch the container creation path from
the default i.e., <cite>/var/lib/lxc</cite> to some other path, which could be a larger
partition mounted on the dispatcher to give more space for such persistent
container users. To set a different container creation path on a per dispatcher
basis <cite>lxc_path</cite> key is used in the dispatcher configuration as described in
<a class="reference internal" href="pipeline-admin.html#dispatcher-configuration"><span class="std std-ref">Extra dispatcher configuration</span></a></p>
<p>Once the <cite>lxc_path</cite> key is set in dispatcher configuration, both persistent and
non-persistent containers will get created in this path.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>LAVA does not have a mechanism to limit the amount of disk space such
persistent containers could use. Hence, administrators should setup
some kind of external monitoring in order to watch the size of these
persistent containers and free space whenever required or destroy
unused persistent containers.</p>
</div>
</section>
<section id="unprivileged-containers-as-root">
<h3>Unprivileged containers as root<a class="headerlink" href="#unprivileged-containers-as-root" title="Permalink to this heading">¶</a></h3>
<p>This is the recommended configuration for running your LXC devices within a
LAVA dispatcher, provided your container does not access any devices attached
to the host. In this configuration the containers will run as unprivileged
user started by root user.</p>
<p>Allocate additional uids and gids to root:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo usermod --add-subuids 100000-165536 root
$ sudo usermod --add-subgids 100000-165536 root
</pre></div>
</div>
<p>Then edit <code class="docutils literal notranslate"><span class="pre">/etc/lxc/default.conf</span></code> and append lxc.uidmap entry like below:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">lxc</span><span class="o">.</span><span class="n">id_map</span> <span class="o">=</span> <span class="n">u</span> <span class="mi">0</span> <span class="mi">100000</span> <span class="mi">65536</span>
<span class="n">lxc</span><span class="o">.</span><span class="n">id_map</span> <span class="o">=</span> <span class="n">g</span> <span class="mi">0</span> <span class="mi">100000</span> <span class="mi">65536</span>
</pre></div>
</div>
<p>With the above in place any container created as root will be an unprivileged
container.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Do not use unprivileged containers when your container has to
interact with a <a class="reference internal" href="glossary.html#term-DUT"><span class="xref std std-term">DUT</span></a> that is attached to the host machine.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>To apply configurations system wide for all LXC devices attached to
the dispatcher use <code class="docutils literal notranslate"><span class="pre">/etc/lxc/default.conf</span></code> file.</p>
</div>
</section>
</section>
<section id="other-resources">
<h2>Other resources<a class="headerlink" href="#other-resources" title="Permalink to this heading">¶</a></h2>
<p>For advanced LXC configurations and usage refer the following links:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://wiki.debian.org/LXC">https://wiki.debian.org/LXC</a></p></li>
<li><p><a class="reference external" href="https://linuxcontainers.org/lxc/getting-started/">https://linuxcontainers.org/lxc/getting-started/</a></p></li>
<li><p><a class="reference external" href="https://help.ubuntu.com/lts/serverguide/lxc.html">https://help.ubuntu.com/lts/serverguide/lxc.html</a></p></li>
<li><p><a class="reference external" href="https://stgraber.org/2013/12/20/lxc-1-0-blog-post-series/">https://stgraber.org/2013/12/20/lxc-1-0-blog-post-series/</a></p></li>
<li><p><a class="reference external" href="https://www.stylesen.org/access_android_devices_lxc">https://www.stylesen.org/access_android_devices_lxc</a></p></li>
<li><p><a class="reference external" href="https://www.stylesen.org/run_android_cts_within_lxc">https://www.stylesen.org/run_android_cts_within_lxc</a></p></li>
</ul>
</section>
</section>


    </div>
      
  </div>
</div>
<footer class="footer">
  <div class="container">
    <p class="pull-right">
      <a href="#">Back to top</a>
      
    </p>
    <p>
        &copy; Copyright 2010-2019, Linaro Limited.<br/>
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 5.3.0.<br/>
    </p>
  </div>
</footer>
  </body>
</html>